package name.sraynal.msgdispatcher.view;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

import name.sraynal.msgdispatcher.controller.Controller;
import name.sraynal.msgdispatcher.event.Event;

public class FilesView extends View {
	
	private String[] fileNames = {"tutu", "tata"};
	
	public FilesView(Controller[] controllers) {
		super(controllers);

	      List menu = new List("Menu Items", Choice.IMPLICIT);
	      
	      for (int i = 0;i < fileNames.length;i++) {
	    	  menu.append(fileNames[i], null);
	      }
	      this.displayable = menu;
	      this.displayable.addCommand(new Command("stop", Command.STOP, 0));
	      this.displayable.setCommandListener(new CommandListener() {

			public void commandAction(Command arg0, Displayable arg1) {
				sendEvent(new Event(Event.FILE_CHOSEN));
			}
	      });
	}

	public void setFileNames(String[] fileNames) {
		this.fileNames = fileNames;
	}
}
